--
-- Author:      name
-- DateTime:    2018-05-05 15:46:15
-- Description: 牛牛服务
local skynet = require "skynet"
local log = require "Log"
local config = require "configquery"
local queue = require "skynet.queue"

local Objects = require "Objects"
local Message = require "niuniu.Message"
local Command = require "niuniu.Command"
local Machine = require("niuniu.Machine")
local Rule = require("niuniu.Rule")




local param = {...}
local tableid = tonumber(param[1])
local room_type = tonumber(param[2])

g_handler = {
	
}

g_objects = Objects.new()


local myqueue = queue()

---------------------------------------------------------
-- REQUEST
---------------------------------------------------------



---------------------------------------------------------
-- CMD
---------------------------------------------------------


local function init()

	local message = Message.new('niuniu')
	g_objects:add(message)

	local rule = Rule.new()
	g_objects:add(rule)

	local machine = Machine.new(tableid,rule)
	g_objects:add(machine)

	local command = Command.new(message,machine,tableid)
	g_objects:add(command)
	g_objects:hotfix("niuniu")
	
	machine:start()
	local f = message:dispatch()
	function _queue( session, source, cmd, ...)		
		local resut = myqueue(f,session, source, cmd, ...)
		return result
	end	
	skynet.dispatch("lua",_queue)

end

---------------------------------------------------------
-- skynet
---------------------------------------------------------
skynet.start(function()
	init()

end)